package com.dolphin.apidriver.controller;

import com.dolphin.apidriver.service.VerificationCodeService;
import com.dolphin.common.dto.ResponseResult;
import com.dolphin.common.request.VerificationCodeDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class VerificationCodeController {
    @Autowired
    VerificationCodeService verificationCodeService;
    @GetMapping("/verification-code")
    public ResponseResult getVerificationCode(@RequestBody  VerificationCodeDTO verificationCodeDTO){

        String driverPhone = verificationCodeDTO.getDriverPhone();
        return verificationCodeService.checkAndSendVerificationCode(driverPhone);
    }

    @PostMapping("verification-code-check")
    public ResponseResult checkVerificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO) {
        String driverPhone = verificationCodeDTO.getDriverPhone();
        String verificationCode = verificationCodeDTO.getVerificationCode();
        System.out.println("司机手机号：" + driverPhone);
        System.out.println("司机验证码：" + verificationCode);
        return  verificationCodeService.checkCode(driverPhone,verificationCode);
    }
}
